class Product:
    def __init__(self, name, price):
        self.name = name
        self.price = price


class Member:
    def __init__(self, level):
        self.level = level

    @property
    def discount_rate(self):
        if self.level == "普通会员":
            return 0.95
        elif self.level == "高级会员":
            return 0.9
        elif self.level == "至尊会员":
            return 0.8
        return 1


class CartItem:
    def __init__(self, product, qty, member=None):
        self.product = product
        self.qty = qty
        self.member = member

    def subtotal(self):
        if self.member:
            return self.product.price * self.qty * self.member.discount_rate
        return self.product.price * self.qty


class ShoppingCart:
    def __init__(self):
        self.items = []

    def add(self, product, qty=1, member=None):
        self.items.append(CartItem(product, qty, member))

    def total(self):
        return sum(item.subtotal() for item in self.items)

    def apply_discount(self):
        return self.total()

    def show(self):
        print("-" * 30)
        for item in self.items:
            if item.member:
                origin_subtotal = item.product.price * item.qty
                print(
                    f"{item.product.name} ×{item.qty}\t原价: ￥{origin_subtotal:.2f}\t折扣后: ￥{item.subtotal():.2f}（会员等级: {item.member.level}）")
            else:
                print(f"{item.product.name} ×{item.qty}\t￥{item.subtotal():.2f}")
        print("-" * 30)
        print(f"应付总额：￥{self.apply_discount():.2f}")


# --- 测试 ---
apple = Product("苹果", 3.5)
bread = Product("面包", 4.0)
cart = ShoppingCart()
normal_member = Member("普通会员")
cart.add(apple, 4, normal_member)
cart.add(bread, 2)
cart.show()
